package cn.com.surker.platform.impl;

import cn.com.surker.platform.PlatformService;
import cn.com.surker.platform.dao.PlatformUserDao;
import cn.com.surker.platform.dao.PlatformUserRoleDao;
import cn.com.surker.platform.entity.PlatformUser;
import cn.com.surker.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author lucky
 * @create 2024年03月01 11:23
 * @desc
 */
@Service
public class PlatformServiceImpl implements PlatformService {

    @Resource
    private PlatformUserDao platformUserDao;
    @Resource
    private PlatformUserRoleDao userRoleDao;

    /**
     * 根据openid查询用户类型
     * @param openid
     * @return
     */
    public Integer queryPlatformType(String openid) {
        if (StringUtils.isNull(openid))
            return -1;

        PlatformUser user = platformUserDao.findByOpenid(openid);
        if (user == null || user.getStatus().intValue() == 1)
            return -1;
        if (StringUtils.isNull(user.getType()))
            return -1;
        return user.getType();
    }
}
